package com.gxa.mobile.annotation;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author IKE <hp1041735092@outlook.jp>
 * @date 24/3/2024
 */
public class PhoneNumValidator implements ConstraintValidator<PhoneNum,String> {
    private static final String VALID_PHONE = "^1\\d{10}$";
    @Override
    public boolean isValid(String phone, ConstraintValidatorContext context) {
        if (phone == null || phone.isEmpty()) {
            return false;
        }
        return phone.matches(VALID_PHONE);
    }
}
